#ifndef __USB_DEVICE_H__
#define __USB_DEVICE_H__

#include <libusb.h>


#define DEV_NAME "/dev/fp256_360_usb_drv"

#define IOCTL_CMD_RW 0x39654127  //读写命令
#define LIBUSB_BULK_TRANSFER_TIMEOUT 1000

#define BulkIoPhase_In			0x80
#define BulkIoPhase_Out 		0x00
#define	BulkIoPhase_Idle		0xff
#define BulkIoSignature			0x43425355
#define BULK_IO_ACK				0x53425355

#define BULK_IO_ACK_1 1
#define BULK_IO_ACK_0 1

#define DEV_PORT_PATH_LEN 200


struct DEV_CMD
{
	unsigned char *buff;       //读写数据缓冲区
	unsigned int write_len;    //写数据长度
	unsigned int read_len;     //读数据长度
	unsigned int timeout;	//
}__attribute__((packed));

typedef struct _USB_DEV_STRUCT_
{
	libusb_device_handle *usbdev_handle;
	uint8 bulk_io_ack_state;//1: 接收到bulk_io_ack; 0: 未接收到bulk_io_ack;

	uint8 dev_port_path_valid_flag;
	char dev_port_path[DEV_PORT_PATH_LEN];

	uint8 autosuspend_flag;//0: 不自动挂起，1: 自动挂起
}USB_DEV_STRUCT;

extern int32 usb_dev_module_init(void);
extern int32 *usb_get_dev_handle(void);
extern int32 usb_dev_open(ofp_dev *dev);
extern int32 usb_dev_close(void);
extern int32 usb_dev_set_null(void);
extern int32 usb_send_data(uint8 *buf, int32 len, int32 *write_len);
extern int32 usb_read_data(uint8 *buf, int32 len, int32 *read_len);
extern int32 usb_test_handle(void);
extern int32 usb_test(void);
extern int print_devs_test(void);
extern int32 usb_dev_get_port_path(void);
extern int usb_dev_enable_autosuspend(void);
extern int usb_dev_disable_autosuspend(void);
extern int usb_dev_set_port_path_valid_flag(uint8 flag);
extern uint8 usb_dev_get_port_path_valid_flag(void);
extern int32 usb_set_autosuspend_flag(uint8 flag);




#endif

